home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 1 / Amiga Tools.iso / egs-tools / egs_demo-version / egs_devels / c-include / egs.h < prev    next >
C/C++ Source or Header  |  1994-06-06  |  19KB  |  558 lines

  1. #ifndef EGS_EGS_H
  2. #define EGS_EGS_H
  3.  
  4. /***************************************************************************\
  5. *  $
  6. *  $ FILE     : egs.h
  7. *  $ VERSION  : 1
  8. *  $ REVISION : 37
  9. *  $ DATE     : 03-Feb-93 12:34
  10. *  $
  11. *  $ Author   : mvk
  12. *  $
  13. *****************************************************************************
  14. *                                                                           *
  15. * (c) Copyright 1990/93 VIONA Development                                   *
  16. *     All Rights Reserved                                                   *
  17. *                                                                           *
  18. \***************************************************************************/
  19.  
  20. #ifndef         EXEC_TYPES_H
  21. #include        <exec/types.h>
  22. #endif
  23. #ifndef         EXEC_PORTS_H
  24. #include        <exec/ports.h>
  25. #endif
  26.  
  27. /*
  28.  * This library is the basic interface to high resolution graphics cards.
  29.  * The hardware is almost completely encapsulated by this module. It is
  30.  * not allowed to access hardware registers directly.
  31.  *
  32.  * The library is designed for full multitasking support. Thus several
  33.  * programs can use the graphics card simultaneously.  Screens can be
  34.  * switched like Intuition screens by pressing the left Amiga key and "S".
  35.  *
  36.  * Moreover, a separate mouse pointer is supported.  The Amiga mouse and
  37.  * EGS mouse can be exchanged by pressing the left Amiga key and "A".
  38.  * If the mouse pointer is on the EGS screen, all key codes are redirected
  39.  * to the screen, too.
  40.  *
  41.  * EGS screens have a message system on their own so that applications with
  42.  * input processing can lack any window without losing multitasking
  43.  * capabilities.
  44.  */
  45.  
  46.  
  47.  
  48. /*
  49.  * EMemNode, EMemPtr
  50.  *
  51.  * Graphics memory on the card is allocated by the procedure AllocEMem.
  52.  * The memory segments are held in EMemNode list structures.  As graphics
  53.  * cards use almost only big consecutive segments, the EGS libraries possess
  54.  * memory management that can move memory in its address location.  To
  55.  * inhibit memory running away while being used, the EMemNode must be locked
  56.  * by incrementing "lock", e.g. when loading "dest" into any address register.
  57.  * "lock" must be decremented after memory access.  The address of the
  58.  * allocated graphics memory is located in the "dest" field.
  59.  * Only the fields "dest" and "lock" are public, all other fields are
  60.  * strictly private.  Example:
  61.  *
  62.  * EMemNode mem;
  63.  * ...
  64.  * mem.lock++;               now mem.dest may be used
  65.  * *mem.dest = $AA;
  66.  * ...(further memory accesses)...
  67.  * mem.lock--;               now mem.dest may not be used any longer
  68.  */
  69.  
  70. /* To access the "lock" component, you would have to use
  71.    "mynode.lock.false.lock", which is simply disgusting !
  72.  
  73.  struct E_EMemNode {
  74.              APTR Dest;
  75.              union {
  76.                 struct {
  77.                     BYTE Lock;
  78.                     UBYTE Display;
  79.                     } false;
  80.                 struct {
  81.                     UWORD Moveable;
  82.                     } true;
  83.                 } Lock;
  84.  
  85.             UWORD Pad_1;
  86.             LONG Size;
  87.             APTR Next, Prev;
  88.            };
  89.  
  90.    But as "moveable" is private to the EGS library, I just ignore the
  91.    memory variation.  If you want to test for moveable then test both
  92.    "lock" and "display".
  93. */
  94.  
  95. typedef struct E_EMemNode *E_EMemPtr;
  96.  
  97. struct E_EMemNode {
  98.     APTR      Dest;
  99.     BYTE      Lock;
  100.     UBYTE     Display;
  101.     UWORD     Pad_1;
  102.     LONG      Size;
  103.     E_EMemPtr Next, Prev;
  104. };
  105.  
  106.  
  107.  
  108. /*
  109.  * EViewPtr
  110.  *
  111.  * Opaque access to a view mode which contains only internal data that is
  112.  * not exported for reasons of compatibility.
  113.  */
  114.  
  115. typedef APTR E_EViewPtr;
  116.  
  117.  
  118.  
  119. /*
  120.  * CLUEntry, CLU, CLUPtr
  121.  *
  122.  * The colour lookup table.  The range of a colour component red, green or
  123.  * blue is 0 to 255, which means all 8 bits are used.  The number of necessary
  124.  * table entries depends on the selected screen depth.  If the CLUT is too
  125.  * short, the missing colours are selected by random.  If no CLUT is
  126.  * specified, a standard CLUT is generated.
  127.  */
  128.  
  129. struct E_CLUEntry {
  130.  UBYTE Red, Green, Blue, Dummy;
  131. };
  132.  
  133. typedef struct E_CLUEntry E_CLU;
  134. typedef E_CLU *E_CLUPtr;
  135.  
  136.  
  137.  
  138. /*
  139.  * EBitMapPtr, EBitMap
  140.  *
  141.  * Basic structure for management of graphics memory.
  142.  *
  143.  * As different graphic boards exist which have different memory organisations
  144.  * the egs libraries offer several different bitmap types.
  145.  *
  146.  * These are the fields that have the same meaning in any bitmap:
  147.  *
  148.  *  .Width       : Pixel Width.
  149.  *  .Height      : Pixel Height.
  150.  *  .BytesPerRow : Number of bytes per row.
  151.  *  .Depth       : Number of bits for one pixel; though in 24 bit mode (real)
  152.  *                 the number 24 is contained herein, always 32 bits (one
  153.  *                 long word) are used.
  154.  *
  155.  *  .Type        : type of bitmap.
  156.  *
  157.  * The different types are:
  158.  *
  159.  *  E_PIXELMAP      : The memory format is chunky which means that the bits that
  160.  *                    build up one pixel lay in adjacent memory locations.
  161.  *                    E.g. 2 bits : aabbccdd eeffgghh iijjkkll ...
  162.  *                    The organisation in 24 bit is RGBx. This is the native egs
  163.  *                    bitmap type. You can allways get an map of these type in
  164.  *                    24 bits. The functions in egsblit are allways able to work
  165.  *                    with this bitmap and convert from and to other 24 bit
  166.  *                    formats, or to other bit depths.
  167.  *                    The real location in memory is
  168.  *
  169.  *                            ..->Typekey.PixelMap.Planes.Dest
  170.  *
  171.  *                    The memory has to be locked before it is accessed or the
  172.  *                    pointer to it, as the libraries are able to move parts
  173.  *                    of the graphicsmemory to gain longer fragments.
  174.  *                    To lock increment the lock field, to unlock decrement it
  175.  *                    again. This lock does not guarantee exclusive access, it
  176.  *                    only guarantees, that the bitmap ist not moved.
  177.  *
  178.  *  E_PIXLACEMAP    : Some graphicsboards have in interlaced an splitted memory
  179.  *                    which means that the odd and the even field of the display
  180.  *                    reside in different memory locations. The format is the
  181.  *                    same as E_pixelMap, with one exception. The even lines
  182.  *                    are in one block and the odd lines are in one block. The
  183.  *                    starting location of the odd field is
  184.  *
  185.  *                      ..->Typekey.PixelMap.Planes.Dest+
  186.  *                       ..->Typekey.PixelMap.IntDisp
  187.  *
  188.  *  E_BITPLANEMAP   : The bits that build each pixel are spread over several
  189.  *                    bitplanes.
  190.  *
  191.  *  E_USERMAP       : Nothing is known about the structure of the frame store.
  192.  *
  193.  *  E_PIXELMAP_xRGB : Same as E_PIXELMAP, exept that the format in 24 bit is
  194.  *                    xRGB and not RGBx.
  195.  *
  196.  * Your programms should be able to handle at least the E_PIXELMAP format. If
  197.  * it can't handle the format it is given, use the routines of the
  198.  * egsblit.library.
  199.  * If you need a bitmap for double buffering you should use the bitmap from
  200.  * your screen as friend bitmap and the flag E_EB_DISPLAYABLE.
  201.  *
  202.  */
  203.  
  204. /*
  205.  
  206.   Enumeration type for access to union fields
  207.  
  208. */
  209.  
  210. #define E_PIXELMAP            0
  211. #define E_PIXLACEMAP          1
  212. #define E_BITPLANEMAP         2
  213. #define E_USERMAP             3
  214. #define E_PIXELMAP_xRGB       4
  215.  
  216. #define E_EB_DISPLAYABLE      1
  217. #define E_EB_BLITABLE         2
  218. #define E_EB_SWAPABLE         4
  219. #define E_EB_NOTSWAPABLE      8
  220. #define E_EB_CLEARMAP         16
  221.  
  222. typedef struct E_EBitMap *E_EBitMapPtr;
  223.  
  224.  
  225. struct E_EBitMap {
  226.  
  227.         WORD    Width, Height, BytesPerRow;
  228.         BYTE    Depth;
  229.         UBYTE   Type; /* Enumeration type descriptor for access to union fields */
  230.         union {
  231.  
  232.             struct {
  233.                 struct   E_EMemNode Planes;
  234.                  ULONG             IntDisp;
  235.                    } PixelMap;
  236.  
  237.             struct {
  238.                 APTR   BitPlanes [24];
  239.                    } BitPlaneMap;
  240.  
  241.             struct {
  242.                 APTR   Action;
  243.                 } UserMap;
  244.  
  245.             } Typekey;
  246.           };
  247.  
  248.  
  249. /* Access example:
  250.  *
  251.  *   E_EBitMapPtr Ptr;
  252.  *   APTR Plane, Otherplane;
  253.  *
  254.  *   if (Ptr->Type == E_BITPLANEMAP)
  255.  *     {
  256.  *     Plane = Ptr->Typekey.BitPlaneMap.BitPlanes[someindex];
  257.  *     }
  258.  *   if (Ptr-Type == E_PIXELMAP)
  259.  *     {
  260.  *     Otherplane = Ptr->Typekey.PixelMap.Planes.Dest;
  261.  *     }
  262.  *
  263.  */
  264.  
  265.  
  266.  
  267. /*
  268.  * SoftMousePtr, SoftMouse, HardMousePtr, HardMouse
  269.  *
  270.  * Data block for the mouse pointer. Three colours can be used. The bits of
  271.  * a pixel are consecutive as usually, the combination %00 represents a
  272.  * transparent pixel.
  273.  *
  274.  * The maximum size of a software mouse pointer is 32 by 32 pixels.  A hard-
  275.  * ware mouse pointer can have up to 64 by 64 pixels but that would exceed
  276.  * the processor capabilities during emulation.
  277.  *
  278.  *
  279.  * EMouse, EMousePtr
  280.  *
  281.  * Definition structure for a mouse pointer.  Each screen can have only one
  282.  * mouse pointer at any moment.  When switching screens, the pointer is
  283.  * changed adequately.  A screen's mouse pointer can be altered by a function
  284.  * at any time.
  285.  *
  286.  * For graphics cards without a hardware pointer a pointer is emulated by
  287.  * software.  Specified HardMouse structures are used only if a hardware
  288.  * pointer was implemented, too.  If .soft = NIL then the HardMouse structure
  289.  * is converted into a SoftMouse structure automatically.
  290.  *
  291.  *  .Color1       : Colour for %01
  292.  *  .Color2       : Colour for %10
  293.  *  .Color3       : Colour for %11.
  294.  *                  These colours are supported only for 4 bit mode and higher.
  295.  *  .XSpot,
  296.  *  .YSpot        : Displacement of the mouse pointer's click pixel.
  297.  *  .Width,
  298.  *  .Height       : Width and Height of the SoftMouse.
  299.  *  .Soft         : Pointer to SoftMouse structure, should always be initia-
  300.  *                  lized for reasons of compatibility.
  301.  *  .Hard         : Pointer to HardMouse structure; if you always want to use
  302.  *                  the small mouse pointer this field should be NIL.
  303.  *
  304.  * Example: The standard mouse pointer.
  305.  *
  306.  *   StdMouse= EMouse:(Color1=$00000001,Color2=$FF0000FF,Color3=$80000080,
  307.  *                     XSpot=1,YSpot=1,Width=25,Height=31,
  308.  *                     Soft=SoftMouse:(
  309.  *  (%01010101000000000000000000000000,%00000000000000000000000000000000),
  310.  *  (%01111111010101010000000000000000,%00000000000000000000000000000000),
  311.  *  (%01111010111111110101010100000000,%00000000000000000000000000000000),
  312.  *  (%01111111101010101111111101010101,%00000000000000000000000000000000),
  313.  *  (%00011111111110101010101011110100,%00000000000000000000000000000000),
  314.  *  (%00011111111111111110101011010000,%00000000000000000000000000000000),
  315.  *  (%00011111111111111111111101000000,%00000000000000000000000000000000),
  316.  *  (%00011111111111111111110100000000,%00000000000000000000000000000000),
  317.  *  (%00010111111111111111101101000000,%00000000000000000000000000000000),
  318.  *  (%00000111111111111111111011010100,%00000000000000000000000000000000),
  319.  *  (%00000111111111111111111110111101,%00000000000000000000000000000000),
  320.  *  (%00000111111111011111111111101111,%01000000000000000000000000000000),
  321.  *  (%00000101111101010111111111111011,%11010100000000000000000000000000),
  322.  *  (%00000001110101010101111111111110,%10111101000000000000000000000000),
  323.  *  (%00000001010101010101111111111111,%11101011010000000000000000000000),
  324.  *  (%00000001010101010101011111111111,%11111010110101000000000000000000),
  325.  *  (%00000001010101010101010111111111,%11111111101111010000000000000000),
  326.  *  (%00000001010101010101010101111111,%11111111111101000000000000000000),
  327.  *  (%00000001010101010101010101111111,%11111111010100000000000000000000),
  328.  *  (%00000000010101010001010101011111,%11111101000000000000000000000000),
  329.  *  (%00000000010101000000010101010111,%11110101010000000000000000000000),
  330.  *  (%00000000010100000000010101010101,%11110101010100000000000000000000),
  331.  *  (%00000000010000000000000101010101,%11010101010101010000000000000000),
  332.  *  (%00000000000000000000000001010101,%01010101010101010100000000000000),
  333.  *  (%00000000000000000000000000010101,%01010101010101010000000000000000),
  334.  *  (%00000000000000000000000000010101,%01010101010101000000000000000000),
  335.  *  (%00000000000000000000000000000101,%01010101010000000000000000000000),
  336.  *  (%00000000000000000000000000000001,%01010101000000000000000000000000),
  337.  *  (%00000000000000000000000000000000,%01010101000000000000000000000000),
  338.  *  (%00000000000000000000000000000000,%01010100000000000000000000000000),
  339.  *  (%00000000000000000000000000000000,%00010000000000000000000000000000),
  340.  *  (%00000000000000000000000000000000,%00000000000000000000000000000000))'PTR);
  341.  */
  342.  
  343. typedef LONG E_HardMouse [64][4];
  344. typedef E_HardMouse *E_HardMousePtr;
  345. typedef LONG E_SoftMouse [32][2];
  346. typedef E_SoftMouse *E_SoftMousePtr;
  347. typedef struct E_EMouse *E_EMousePtr;
  348.  
  349. struct E_EMouse {
  350.  
  351.    LONG           Color1, Color2, Color3;
  352.    WORD           XSpot, YSpot;
  353.    WORD           Width, Height;
  354.    E_SoftMousePtr Soft;
  355.    E_HardMousePtr Hard;
  356.  
  357. };
  358.  
  359.  
  360.  
  361. /*
  362.  * EScrFlags, EScrFlagSet, EScreen, EScreenPtr, NewEScreen...
  363.  *
  364.  * EScreens are structures with capabilities as follows:
  365.  *  - Management of resolution mode (EViewPtr)
  366.  *  - Management of graphics memory (EBitMap)
  367.  *  - Message system for user input
  368.  * Please note that an EScreen is different from the EGSIntui screens, i.e.
  369.  * NO window can be opened on any EScreen; for that purpose an EGSIntui screen
  370.  * must be created.
  371.  *
  372.  * EScrFlags
  373.  *    SCREENBEHIND : The new screen is opened behind all other screens.
  374.  *    OWNBITMAP    : The screen has a user defined BitMap.
  375.  *    LACESCREEN   : The screen is to be opened as interlaced to decrease
  376.  *                   video line frequency in spite of knowing the flicker
  377.  *                   (currently without meaning).
  378.  *
  379.  * NewEScreen
  380.  *  .Mode          : Name of the selected video mode ending with a null byte.
  381.  *  .Depth         : Required bit depth (1, 2, 4, 6, 8, 12, 16 or 24).
  382.  *                   Allowed pixel depths depend on the underlying hardware,
  383.  *                   and may vary for different screen modes. The suggested
  384.  *                   way to retrieve data for supported modes and depths is
  385.  *                   by the use of 'E_GetHardInfo'.
  386.  *  .Colors        : An own CLUT if required; if NIL the standard CLUT is used.
  387.  *  .Map           : Possibly a user BitMap which has to be allocated
  388.  *                   previously.
  389.  *  .Flags         : Flags for the new screen (only "SCREENBEHIND").
  390.  *  .Mouse         : Possibly a user mouse pointer.
  391.  *  .EdcmpFlags    : Messages to be sent.
  392.  *  .Port          : Possibly an application message port; must be removed
  393.  *                   before closing the screen (or crash).
  394.  */
  395.  
  396. /* Corresponding EScrFlagSet has 32 bits ! */
  397. #define E_SCREENBEHIND 1
  398. #define E_OWN_BITMAP    2
  399. #define E_LACESCREEN   4
  400.  
  401. struct E_NewEScreen {
  402.       char            *Mode;
  403.       UWORD            Depth;
  404.       UWORD            Pad_1;
  405.       E_CLUPtr         Colors;
  406.       E_EBitMapPtr     Map;
  407.       ULONG            Flags;
  408.       E_EMousePtr      Mouse;
  409.       ULONG            EdcmpFlags;
  410.       struct MsgPort  *Port;
  411. };
  412.  
  413. /*
  414.  * EScreen
  415.  *  .Prev,
  416.  *  .Next          : Internal chaining.
  417.  *  .View          : !!!! PRIVATE !!!!
  418.  *  .Map           : Pointer to the screen's BitMap structure.
  419.  *  .Colors        : !!!! PRIVATE !!!!
  420.  *  .Mouse         : EMouse structure (READ ONLY !!!!).
  421.  *  .MouseOn       : !!!! PRIVATE !!!!
  422.  *  .EdcmpFlags    : Message flags (READ ONLY !!!).
  423.  *  .Port          : Screen's message port.
  424.  *  .BackLink      : Link field for users, e.g. used by EGSIntui.
  425.  *  .MouseX,
  426.  *  .MouseY        : Always the current mouse position on the screen.
  427.  */
  428.  
  429. typedef struct E_EScreen *E_EScreenPtr;
  430.  
  431. struct E_EScreen {
  432.  
  433.    E_EScreenPtr       Prev, Next;
  434.    E_EViewPtr         View;
  435.    E_EBitMapPtr       Map;
  436.    E_CLUPtr           Colors;
  437.    E_EMousePtr        Mouse;
  438.    ULONG              Flags;
  439.    UBYTE              MouseOn;
  440.    UBYTE              Pad_1;
  441.    UBYTE              Pad_2;
  442.    UBYTE              Pad_3;
  443.    ULONG              EdcmpFlags;
  444.    struct MsgPort    *Port;
  445.    APTR               BackLink;
  446.    WORD               MouseX, MouseY;
  447. };
  448.  
  449.  
  450.  
  451. /*
  452.  * EDCMPFlags, EDCMPFlagSet, EGSMsgPtr, EGSMessage
  453.  *
  454.  * Structures for the message system working on the EScreen level.  Thus
  455.  * mouse and character input can be gained without opening a window.
  456.  *
  457.  * EDCMPFlags:
  458.  *   eMOUSEBUTTONS  : Mouse buttons were pressed
  459.  *   eMOUSEMOVE     : Mouse was moved
  460.  *   eRAWKEY        : Key code from the keyboard
  461.  *   eINTUITICK     : Timer is calling
  462.  *   eDISKINSERTED  : Disk was inserted
  463.  *   eDISKREMOVED   : Disk was removed
  464.  *   eNEWPREFS      : Preferences have been changed
  465.  *
  466.  *  .Class          : Type of the message
  467.  *  .Code           : Message code (refer to  "InputEvents")
  468.  *  .Qualifier      : Message code (refer to  "InputEvents")
  469.  *  .IAddress       : (For E_eRAWKEY: Pointer to deadkey array )
  470.  *  .MouseX,
  471.  *  .MouseY         : Mouse position
  472.  *  .Second,
  473.  *  .Micros         : Event time
  474.  *  .EdcmpScreen    : Screen sending the message
  475.  */
  476.  
  477. /* Corresponding EDCMPFlagSet has 32 bits ! */
  478. #define E_eMOUSEBUTTONS 1
  479. #define E_eMOUSEMOVE    2
  480. #define E_eRAWKEY       4
  481. #define E_eTIMETICK     8
  482. #define E_eDISKINSERTED 16
  483. #define E_eDISKREMOVED  32
  484. #define E_eNEWPREFS     64
  485.  
  486. typedef struct E_EGSMessage *E_EGSMsgPtr;
  487.  
  488. struct E_EGSMessage {
  489.  
  490.   struct Message  Msg;                 /* has long word size */
  491.   ULONG           Class;
  492.   UWORD           Code;
  493.   UWORD           Qualifier;
  494.   APTR            IAddress;
  495.   WORD            MouseX, MouseY;
  496.   ULONG           Seconds, Micros;
  497.   E_EScreenPtr    EdcmpScreen;
  498. };
  499.  
  500.  
  501. /*
  502.  * ScreenMode, ScreenModePtr
  503.  *
  504.  * Information on supported screen modes and depths. The list including
  505.  * these modes is found by 'GetHardInfo'.
  506.  *
  507.  *  .ln_Name : The name of the mode, for use in 'E_OpenScreen' ...
  508.  *  .Horiz     : The horizontal resolution
  509.  *  .Vert      : The vertical resolution
  510.  *  .Depths    : The supported pixel depths in this mode. Each depth is
  511.  *               represented in one bit. E.g. (1<<24) & mode->depths for
  512.  *               24 bit.
  513.  */
  514.  
  515. typedef struct E_ScreenMode *E_ScreenModePtr;
  516.  
  517. struct E_ScreenMode {
  518.  
  519.       struct   Node Node;
  520.       UWORD         Pad;
  521.       UWORD         Horiz, Vert;
  522.       ULONG         Depths;
  523.  
  524. };
  525.  
  526.  
  527. /*
  528.  * To realize the highest possible compatibility between different graphics
  529.  * cards, the library must offer a function giving information about the
  530.  * current card plugged in.  Among these information items are the resolutions
  531.  * that the card implements.
  532.  * That task is carried out by the HardInfo structure and the procedure
  533.  * "GetHardInfo".
  534.  */
  535.  
  536. /* Corresponding HardInfoFlagSet has 32 bits ! */
  537. #define E_HARD_BLITTER      1
  538. #define E_HARD_BOOTROM      2
  539. #define E_HARD_VBLANK       4
  540. #define E_HARD_REALMODE     8
  541. #define E_HARD_GAMMACORRECT 16
  542. #define E_HARD_PLANES       32
  543.  
  544. typedef struct E_HardInfo *E_HardInfoPtr;
  545.  
  546. struct E_HardInfo {
  547.      char     *Product, *Manufact, *Name;
  548.      WORD      Version, MaxFreq;
  549.      ULONG     Flags;
  550.      struct    List *Modes;
  551.      WORD      ActPixClock, FrameTime;
  552.      APTR      MemBase;
  553.      LONG      MemSize;
  554.      char     *LibDate;
  555. };
  556.  
  557. #endif  /* EGS_EGS_H */
  558.